<datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration">

    <providers>
        <provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider>
    </providers>

    <datasources>

        <datasource>
            <name>WSO2_CARBON_DB</name>
            <description>The datasource used for registry and user manager</description>
            <jndiConfig>
                <name>jdbc/WSO2CarbonDB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>{{database.local.url}}</url>
                    <username>{{database.local.username}}</username>
                    <password>{{database.local.password}}</password>
                    <driverClassName>{{database.local.driver}}</driverClassName>
                    <validationQuery>{{database.local.validationQuery}}</validationQuery>
                    {% for property_name,property_value in database.local.pool_options.items() %}
                    <{{property_name}}>{{property_value}}</{{property_name}}>
                    {% endfor %}
                </configuration>
            </definition>
        </datasource>

        <datasource>
            <name>WSO2_SHARED_DB</name>
            <description>Shared Database for user and registry data</description>
            <jndiConfig>
                <name>jdbc/SHARED_DB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>{{database.shared_db.url}}</url>
                    <username>{{database.shared_db.username}}</username>
                    <password>{{database.shared_db.password}}</password>
                    <driverClassName>{{database.shared_db.driver}}</driverClassName>
                    <validationQuery>{{database.shared_db.validationQuery}}</validationQuery>
                    {% for property_name,property_value in database.shared_db.pool_options.items() %}
                    <{{property_name}}>{{property_value}}</{{property_name}}>
                        {% endfor %}
                 </configuration>
            </definition>
        </datasource>

{% if database.user is defined %}
        <datasource>
            <name>WSO2USER_DB</name>
            <description>User related database</description>
            <jndiConfig>
                <name>jdbc/WSO2USER_DB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>{{database.user.url}}</url>
                    <username>{{database.user.username}}</username>
                    <password>{{database.user.password}}</password>
                    <driverClassName>{{database.user.driver}}</driverClassName>
                    <validationQuery>{{database.user.validationQuery}}</validationQuery>
                    {% for property_name,property_value in database.user.pool_options.items() %}
                    <{{property_name}}>{{property_value}}</{{property_name}}>
                        {% endfor %}
                 </configuration>
            </definition>
        </datasource>
{% endif%}

{% if database.sync_runtime_artifacts_db is defined %}
        <datasource>
            <name>WSO2AS_DB</name>
            <description>The datasource used for Artifact synchronizer feature</description>
            <jndiConfig>
                <name>jdbc/WSO2AS_DB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>{{database.sync_runtime_artifacts_db.url}}</url>
                    <username>{{database.sync_runtime_artifacts_db.username}}</username>
                    <password>{{database.sync_runtime_artifacts_db.password}}</password>
                    <driverClassName>{{database.sync_runtime_artifacts_db.driver}}</driverClassName>
                    <validationQuery>{{database.sync_runtime_artifacts_db.validationQuery}}</validationQuery>
                    {% for property_name,property_value in database.sync_runtime_artifacts_db.pool_options.items() %}
                    <{{property_name}}>{{property_value}}</{{property_name}}>
                    {% endfor %}
                </configuration>
            </definition>
        </datasource>
{% endif%}

{% if database.config is defined %}
        <datasource>
            <name>WSO2CONFIG_DB</name>
            <description>Database for config registry</description>
            <jndiConfig>
                <name>jdbc/WSO2CONFIG_DB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>{{database.config.url}}</url>
                    <username>{{database.config.username}}</username>
                    <password>{{database.config.password}}</password>
                    <driverClassName>{{database.config.driver}}</driverClassName>
                    <validationQuery>{{database.config.validationQuery}}</validationQuery>
                    {% for property_name,property_value in database.config.pool_options.items() %}
                    <{{property_name}}>{{property_value}}</{{property_name}}>
                        {% endfor %}
                 </configuration>
            </definition>
        </datasource>
{% endif%}

        {% for data in datasource %}
        <datasource>
            <name>{{data.id}}</name>
            <description>this database is {{data.id}}</description>
            <jndiConfig>
                <name>jdbc/{{data.id}}</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                     <url>{{data.url}}</url>
                     <username>{{data.username}}</username>
                     <password>{{data.password}}</password>
                     <driverClassName>{{data.driver}}</driverClassName>
                     <validationQuery>{{data.validationQuery}}</validationQuery>
                    {% for property_name,property_value in data.pool_options.items() %}
                     <{{property_name}}>{{property_value}}</{{property_name}}>
                    {% endfor %}
                </configuration>
            </definition>
        </datasource>
        {% endfor %}
        <datasource>
            <name>WSO2AM_DB</name>
            <description>The datasource used for API Manager database</description>
            <jndiConfig>
                <name>jdbc/WSO2AM_DB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>{{database.apim_db.url}}</url>
                    <username>{{database.apim_db.username}}</username>
                    <password>{{database.apim_db.password}}</password>
                    <driverClassName>{{database.apim_db.driver}}</driverClassName>
                    <validationQuery>{{database.apim_db.validationQuery}}</validationQuery>
                    {% for property_name,property_value in database.apim_db.pool_options.items() %}
                    <{{property_name}}>{{property_value}}</{{property_name}}>
                        {% endfor %}
            </configuration>
            </definition>
        </datasource>


        <datasource>
            <name>WSO2_MB_STORE_DB</name>
            <description>The datasource used for message broker database</description>
            <jndiConfig>
                <name>WSO2MBStoreDB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>{{database.mb.store_db.url}}</url>
                    <username>{{database.mb.store_db.username}}</username>
                    <password>{{database.mb.store_db.password}}</password>
                    <driverClassName>{{database.mb.store_db.driver}}</driverClassName>
                    <validationQuery>{{database.mb.store_db.validationQuery}}</validationQuery>
                    {% for property_name,property_value in database.mb.store_db.pool_options.items() %}
                    <{{property_name}}>{{property_value}}</{{property_name}}>
                        {% endfor %}
                </configuration>
            </definition>
        </datasource>
    </datasources>

</datasources-configuration>
